function foo() {
  let a = 1;
  return function () {
    return a;
  };
}

const baz = foo();

baz();

function debounce(fn, wait) {
  let timer = null;

  return function () {
    if (timer) return clearTimeout(timer);
    setTimeout(fn, wait);
  };
}

function throttle(fn, wait) {
  let timer = null;
  return function () {
    if (timer) return;
    setTimeout(fn, wait);
  };
}
